*This is the data analysis part of the program.
*This is used when the variables must be calculated, some more data entered, and then analyzed.
;

PROC IMPORT OUT= WORK.one DATAFILE= "C:\Users\tebert\OneDrive - University of Florida\Work\Manuscipts\Gender size\Weight 2\EbertTplus.xlsx" 
 DBMS=xlsx REPLACE;
 SHEET="EbertTPlus"; 
 GETNAMES=YES;
RUN;
data one; set one;
if sex="F" then sex="f";
if sex="M" then sex="m";
if color1="B" then color1="b";
if color1="G" then color1="g";
run;
data one; set one;
if sex="m" then sex="male";
if sex="f" then sex="female";
if color1="b" then color1="blue";
if color1="g" then color1="green";
run;
/*
data one; set one;
proc sort; by sex;
proc means; by sex;
proc sort; by color1;
proc means; by color1;
proc sort; by sex color1;
proc means; by sex color1;
run;
/*
proc glm plots=diagnostics;
model head=head|femur;
lsmeans sex;
lsmeans color1;
run;


model femur=head|femur;
lsmeans sex;
lsmeans color1;
run;
*/;
data two; set one;
*femur=log(femur);
*head=log(head);
run;

ods graphics on;
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model NumPrbs= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of NumPrbs';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model MnPrbs= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of MnPrbs';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model sdPrbs= sex|color1 ; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of sdPrbs';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model MdnPrbs= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of MdnPrbs';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model DurFrstPrb= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of DurFrstPrb';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model DurScndPrb= sex|color1 ; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of DurScndPrb';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TtlPrbTm= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of TtlPrbTm';*duration of recording less duration of NP or Z;

*******************************************************************;
******** Variables for NP *************************;
*******************************************************************;
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model NumNP= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of NumNP';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TtlDurNP= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of TtlDurNP';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model MnDurNP= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of MnDurNP';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model sdNP= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of sdNP';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TmFrstPrbFrmStrt= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of TmFrstPrbFrmStrt'; *Duration of first NP;
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model DurScndZ= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of DurScndZ'; *Duration of second NP;
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model DurNnprbBfrFrstE1= sex|color1 ; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of DurNnprbBfrFrstE1';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model DurNpFllwFrstSusE2= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of DurNpFllwFrstSusE2';

*******************************************************************;
******** Variables for C or Pathway (=C+A+B) *************;
*******************************************************************;
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model NmbrC= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of NmbrC';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TtlDurC= sex|color1 ; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of TtlDurC';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model MnDurC= sex|color1 ; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of MnDurC';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model sdC= sex|color1 ; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of sdC';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model NmbrShrtC= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of NmbrShrtC';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model ShrtCbfrE1= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of ShrtCbfrE1';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model PrcntPrbC= sex|color1 ; title 'ANOVA & LSD of PrcntPrbC';

*******************************************************************;
******** Variables for G *************************;
*******************************************************************;
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model NumG= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of NumG';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model DurG= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of DurG';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model MeanG= sex|color1 ; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of MeanG';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model sdG= sex|color1 ; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of sdG';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model CtoFrstG= sex|color1 ; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of CtoFrstG';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model DurNnprbBfrFrstG= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of DurNnprbBfrFrstG';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model meanNGPrb= sex|color1 ; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of meanNGPrb';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TmFrmFrstPrbFrstG= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of TmFrmFrstPrbFrstG';
***** This one is close;
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TmBegPrbFrstG= sex|color1 ; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of TmBegPrbFrstG';

proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model NumPrbsAftrFrstG= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of NumPrbsAftrFrstG';
****** Another close one;
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model NmbrShrtPrbAftrFrstG= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of NmbrShrtPrbAftrFrstG';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model NumLngG= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of NumLngG';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TmFrstSusGFrstPrb= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of TmFrstSusGFrstPrb';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model PrcntPrbG= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of PrcntPrbG';

*******************************************************************;
******** Variables for D *************************;
*******************************************************************;
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model NumD= sex|color1 ; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of NumD';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TtlDurD= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of TtlDurD';
***Good, but model not significant;
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model MeanD= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of MeanD';
**** but model not significant;
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model sdD= sex|color1 ; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of sdD';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model CtoFrstD= sex|color1 ; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of CtoFrstD';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model DurNnprbBfrFrstD= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of DurNnprbBfrFrstD';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model meanNDPrb= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of meanNDPrb';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TmFrmFrstPrbFrstD= sex|color1 ; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of TmFrmFrstPrbFrstD';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TmBegPrbFrstD= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of TmBegPrbFrstD';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model NumPrbsAftrFrstD= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of NumPrbsAftrFrstD';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model NmbrShrtPrbAftrFrstD= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of NmbrShrtPrbAftrFrstD';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model NumLngD= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of NumLngD';
**So good, yet most of the data was removed because only 12 insects had a sustained D;
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TmFrstSusDFrstPrb= sex|color1; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of TmFrstSusDFrstPrb';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model MaxD= sex|color1 ; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of MaxD';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model PrcntPrbD= sex|color1 ; *lsmeans trt/pdiff lines; title 'ANOVA & LSD of PrcntPrbD';
*/;
*******************************************************************;
******** Variables for E or E1 *************************;
*******************************************************************;
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model NumE1= sex|color1 ; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of NumE1';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TtlDurE1= sex|color1 ; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of TtlDurE1';
***Here is one example MnDurE1;
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model MnDurE1= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of MnDurE1';
***And another;
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model sdE1= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of sdE1';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model CtoFrstE1= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of CtoFrstE1';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TmFrmFrstPrbFrstE= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of TmFrmFrstPrbFrstE';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TmBegPrbFrstE= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of TmBegPrbFrstE';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model NumPrbsAftrFrstE= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of NumPrbsAftrFrstE';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model NmbrShrtPrbAftrFrstE= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of NmbrShrtPrbAftrFrstE';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model NumLngE1BfrE2= sex|color1 ; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of NumLngE1BfrE2';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model NumSnglE1= sex|color1 ; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of NumSnglE1';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model DurFirstE= sex|color1 ; title 'ANOVA & LSD of DurFirstE';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model CntrbE1toE= sex|color1 ; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of CntrbE1toE';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model DurE1FlwdFrstSusE2= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of DurE1FlwdFrstSusE2';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model DurE1FlldFrstE2= sex|color1 ; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of DurE1FlldFrstE2';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TtlDurE1FlldSusE2= sex|color1 ; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of TtlDurE1FlldSusE2';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TtlDurE1FlldE2= sex|color1 ; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of TtlDurE1FlldE2';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TtlDurSnglE1= sex|color1 ; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of TtlDurSnglE1';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model PrcntPrbE1= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of PrcntPrbE1';

*******************************************************************;
******** Variables for E2 *************************;
*******************************************************************;
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model NumE2= sex|color1 ; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of NumE2';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model NumLngE2= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of NumLngE2';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TtlDurE2= sex|color1 ; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of TtlDurE2';
***MnDurE2 and sdE2 have a significant three-way interaction term, but neither model is significant.;
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model MnDurE2= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of MnDurE2';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model sdE2= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of sdE2';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TmFrstSusE2FrstPrb= sex|color1 ; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of TmFrstSusE2FrstPrb';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TmFrstSusE2StrtPrb= sex|color1 ; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of TmFrstSusE2StrtPrb';

proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TmFrstE2StrtEPG= sex|color1 ; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of TmFrstE2StrtEPG';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TmFrstE2FrmFrstPrb= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of TmFrstE2FrmFrstPrb';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TmFrstE2FrmPrbStrt= sex|color1 ; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of TmFrstE2FrmPrbStrt';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TmLstE2EndRcrd= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of TmLstE2EndRcrd';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model maxE2= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of maxE2';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model PrcntPrbE2= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of PrcntPrbE2';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model PrcntE2SusE2= sex|color1 ; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of PrcntE2SusE2';

*******************************************************************;
******** Variables for E1+E2 *************************;
*******************************************************************;
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model PotE2Indx= sex|color1 ; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of PotE2Indx';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TtlDurE= sex|color1 ; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of TtlDurE';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TtlDurE1FllwdE2PlsE2= sex|color1 ; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of TtlDurE1FllwdE2PlsE2';
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TotDurNnPhlPhs= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of TotDurNnPhlPhs';*Duration of recording less E1 and E2;
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model TmFrstSusE2= sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of TmFrstSusE2';

/*
TtlDurNP
DurNnprbBfrFrstE1
DurNnprbBfrFrstD
TmFrmFrstPrbFrstD
TmFrmFrstPrbFrstE
TmFrstSusE2FrstPrb
TmFrstE2StrtEPG
TmFrstE2FrmFrstPrb
TmFrstSusE2
*/;

Proc glm data=two plots=contourfit plots=diagnostics;
model TmFrstSusE2=head;
Proc glm data=two plots=contourfit plots=diagnostics;
model TmFrstSusE2=femur;
run;

Proc glm plots=contourfit plots=diagnostics;
model TmFrmFrstPrbFrstE=femur;
Proc glm plots=contourfit plots=diagnostics;
model TmFrmFrstPrbFrstE=head;
run;

Proc glm plots=contourfit plots=diagnostics;
model TmFrstSusE2=femur;
Proc glm plots=contourfit plots=diagnostics;
model TmFrstSusE2=head;
run;

Proc glimmix data=two plots=residualpanel; class sex color1; model TmFrstSusE2= head|sex|color1; *lsmeans trt/adjust=tukey pdiff lines; title 'ANOVA & LSD of TmFrstSusE2';
proc glm plots=contourfit plots=diagnostics; class sex color1; model TmFrstSusE2= head|sex|color1;
proc glm data=two plots=diagnostics plots=contourfit; class sex color1; model NumPrbs= head sex color1; title 'ANOVA & LSD of NumPrbs';
